package com.lei.Proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author: leiGer
 * @Date: 2021/01/16
 * @Time: 22:52
 */
//处理程序
public class LogHandler implements InvocationHandler {
    Movable move;

    public LogHandler(Movable m) {
        this.move = m;
    }

    public void before(){
        System.out.println("method start...");
    }
    public void after(){
        System.out.println("method end...");
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        before();
        Object obj = method.invoke(move, args);
        after();
        return obj;
    }
}
